<template>
  <div>
    <el-table :data="tableData" style="width: 100%"  >
      <el-table-column label="" width="40" >
        <template #default="scope">
          <div style="display: flex; align-items: center">
            <el-checkbox
              @change="changeStatus"
              v-model="scope.row.checked"
              label=""
              size="large"
            />
          </div>
        </template>
      </el-table-column>
      <el-table-column label="订单信息" width="140">
        <template #default="scope">
          <div class="mesg">
            <p class="col">{{ "E" + scope.row.orderNum }}</p>
            <p class="font">{{ scope.row.name }}&nbsp;{{ scope.row.phone }}</p>
            <p class="font">{{ scope.row.time }}</p>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="" width="30" type="expand">
        <template>
          <div class="mesg">
          </div>
        </template>
      </el-table-column>
      <el-table-column label="车次/类型" width="90">
        <template #default="scope">
          <p>{{ scope.row.carone }}</p>
          <p>{{ scope.row.cartype }}</p>
        </template>
      </el-table-column>
      <el-table-column label="出发/始发站" width="140">
        <template #default="scope">
          <p><el-tag>始</el-tag>{{ scope.row.startLocation }}</p>
          <p><el-tag type="success">终</el-tag>{{ scope.row.endLocation }}</p>
        </template>
      </el-table-column>
      <el-table-column label="出发/始发时间" width="160">
        <template #default="scope">
          <div
            style="
              display: flex;
              flex-direction: column;
              justify-content: space-around;
              align-items: center;
            "
          >
            <p>{{ scope.row.startTime.split(" ")[1].slice(0, 5) }}</p>
            <p>{{ scope.row.endTime.split(" ")[1].slice(0, 5) }}</p>
          </div>
        </template>
      </el-table-column>

      <el-table-column label="乘车人/出发日期" width="160">
        <template #default="scope">
          <div
            style="
              display: flex;
              flex-direction: column;
              justify-content: space-around;
              align-items: center;
            "
          >
            <p>{{ scope.row.name }}</p>
            <p>{{ scope.row.startTime.split(" ")[0] }}</p>
          </div>
        </template>
      </el-table-column>

      <el-table-column label="票价/车厢座号/坐席类型" width="165">
        <template #default="scope">
          <div class="bb">
            <p class="pri">{{ "￥" + scope.row.prices }}</p>
            <p>{{ scope.row.carcar }}</p>
            <p>{{ scope.row.sitType }}</p>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="状态" width="140">
        <template #default="scope">
          <p >{{ scope.row.payStatus}}</p>
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template #default="scope">
          <p>
            <el-button size="small" @click="handleEdit(scope.$index, scope.row)"
              >编辑</el-button
            >
          </p>
          <p>
            <el-button
              size="small"
              type="danger"
              @click="handleDelete(scope.$index, scope.row)"
              >删除</el-button
            >
          </p>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
  
  <script setup>
import { defineProps, ref, defineEmits } from "vue";

const props = defineProps({
  tableData: {
    type: Array,
  },
  currentPage: {
    type: Number,
  },
  pageSize: {
    type: Number,
  },
});

// const checked = ref(false);
// console.log(currentPage);
// 实例化自定义事件
const emit = defineEmits();
const handleEdit = (index, row) => {
  console.log(index);
  //  // 通知父组件进行编辑
  emit("edit", {
    id: row.id,
    row,
    index,
    currentPage: props.currentPage,
    pageSize: props.pageSize,
  });
};
const handleDelete = (index, row) => {
  // 通知父组件进行删除
  emit("del", {
    id: row.id,
    index,
    currentPage: props.currentPage,
    pageSize: props.pageSize,
  });
};

const changeStatus = (flag) => {
  console.log(flag);
  emit("changeFlag",flag)
};
</script>
  
  <style scoped>
.sp, .pri {
  color: #ff8d41;
}


.mesg {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-around;
}
.font {
  font-size: 12px;
}
.col {
  color: #1ba9ba;
}

.bb {
  display: flex;
  align-items: center;
  flex-direction: column;
}
</style>